<template>
  <div class="body">
    <el-form class="form" :model="form" label-width="100px" ref="form">
      <h3 class="title">Nuxtcui项目</h3>
      <el-form-item label="用户名">
        <el-input style="width: 200px" v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input
          type="password"
          style="width: 200px"
          v-model="form.password"
        ></el-input>
      </el-form-item>
      <el-form-item label="记住我">
        <el-switch v-model="form.remeber"></el-switch>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">登录</el-button>
        <el-button>清空</el-button>
        <el-link style="margin-left: 10px" type="primary" :underline="false">新用户注册</el-link>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {},
    };
  },
  methods: {
   async onSubmit() {
      console.log(this.form);
      await this.$store.dispatch('users/doLogin',this.form)
      this.$router.push('/')
    },
  },
};
</script>

<style>
body {
  /* background-color:grey; */
  background-image: url("../static/img/background.jpg");
  background-size: 100%;
  overflow-y: hidden;
  position: relative;
}

.title {
  text-align: center;
}

.form {
  width: 345px;
  height: 326px;
  background-color: azure;
  position: absolute;
  top: 20%;
  left: 72%;
}

</style>